// pages/admin/home/index.js
const cacheHelper = require('../../../helper/cache_helper.js');
const constants = require('../../../setting/constants.js');

Page({

    /**
     * 页面的初始数据
     */
    data: {
        admin_info: {
            name: '***',
            last: '2024-01-01 12:00:00',
            cnt: '0',
            type: '0',
        },
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        let loginInfo = cacheHelper.get(constants.CACHE_ADMIN);
        if (!loginInfo) {
            // 跳转登陆页面
            wx.reLaunch({
              url: '/pages/admin/login/index',
            })
        } else {
            // 登录信息
            this.setData({
                admin_info: {
                    ...this.data.admin_info,
                    name: loginInfo.name,
                    last: loginInfo.last,
                    cnt: loginInfo.cnt,
                    type: loginInfo.type,
                }
            })
        }
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

})